using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public enum HUDType
{
	HPNumberHUD,
	NameHUD
}

public class BattleUI : MonoBehaviour
{
	public static BattleUI instance;
	
	
	public GameObject HPNumberHUDTemplate;
	public GameObject NameHUDTemplate;
	
	public List<HUD> huds = new List<HUD>();
	
	void Awake()
	{
		instance = this;
	}
	
	void Destroy()
	{
		instance = null;
	}
	
	public HUD CreateHUD(HUDType type, GameObject target)
	{
		GameObject hudObject;
		GameObject template;
		switch(type)
		{
		case HUDType.HPNumberHUD:
			template = HPNumberHUDTemplate;
			break;
		case HUDType.NameHUD:
			template = NameHUDTemplate;
			break;
		default:
			return null;
		}

		hudObject = GameObject.Instantiate(template) as GameObject;
		hudObject.transform.parent = template.transform.parent;
		hudObject.transform.localScale = template.transform.localScale;

		HUD hud = hudObject.GetComponent<HUD>();
		hud.SetUp(target);
		huds.Add(hud);

		hudObject.SetActive(true);
		return hud;
	}
	
	public void RemoveHUD(HUD hud)
	{
		huds.Remove(hud);
		GameObject.Destroy(hud.gameObject);
	}
	
}
